Skip to main content

Last Update: 2025/3/26

OpenAI Image Generation API

The OpenAI Image Generation API allows you to create images from textual descriptions using OpenAI's DALL-E model. This document provides an overview of the API endpoints, request parameters, and response structure.

Endpoint

POST https://platform.llmprovider.ai/v1/images/generations

Request Headers

HeaderValue
AuthorizationBearer YOUR_API_KEY
Content-Typeapplication/json

Request Body

The request body should be a JSON object with the following parameters:

ParameterTypeDescription
modelstringThe model to use for image generation.
promptstringA text description of the desired image(s).
ninteger(Optional) The number of images to generate. Defaults to 1.
qualitystring(Optional) The quality of the generated images. Options: "standard" or "hd".
response_formatstring(Optional) The format of the generated images. Options: "url" or "b64_json".
sizestring(Optional) The size of the generated images. Options: "256x256", "512x512", "1024x1024", "1792x1024", "1024x1792".
stylestring(Optional) A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse.
userstring(Optional) A unique identifier for tracking your requests.

Example Request

{
"model": "dall-e-3",
"prompt": "A cute baby sea otter",
"n": 1,
"size": "1024x1024",
"response_format": "url"
}

Response Body

The response body will be a JSON object containing the generated images and related metadata.

FieldTypeDescription
createdintegerThe timestamp for when the image was created.
dataarrayAn array of generated image objects.

Example Response

{
"created": 1678891234,
"data": [
{
"url": "https://..."
},
{
"url": "https://..."
}
]
}

Example Request

curl -X POST https://platform.llmprovider.ai/v1/images/generations \
-H "Authorization: Bearer $YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "dall-e-3",
"prompt": "A cute baby sea otter",
"n": 1,
"size": "1024x1024"
}'

For more details, refer to the OpenAI API documentation.